package homeWork;/*import java.util.Scanner;

public class homeWork6 {
    public static void main (String[] args){
        int code = 12345;
        System.out.println("请输入密码");
        Scanner sc = new Scanner(System.in);
        int inputCode = sc.nextInt();
        for (int i = 0; i < 3; i++) {
            if (inputCode == code){
                System.out.println("登录成功");
            }else {
                System.out.println("密码错误");
            }
        }
    }
}*/
import java.util.Scanner;

public class homeWork6 {
    public static void main(String[] args) {
        String correctPassword = "123456"; // 设置正确的密码
        String inputPassword;
        int attempts = 0;
        Scanner scanner = new Scanner(System.in);

        while (attempts < 3) {
            System.out.print("请输入密码: ");
            inputPassword = scanner.nextLine();
            attempts++;

            if (inputPassword.equals(correctPassword)) {
                System.out.println("登录成功");
                break;
            } else {
                if (attempts < 3) {
                    System.out.println("密码错误，请重新输入。");
                } else {
                    System.out.println("三次输入错误，退出程序。");
                }
            }
        }
        scanner.close();
    }
}

